﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Windows.Markup;

namespace CCF20
{
    public enum EnumBoolToStringTableName
    {
        故障,
        设备
    }
    public enum EnumFaultType
    {
        故障,
        里程,
        撞车
    }
    public enum EnumContactResult
    {
        没有联络上,
        还未决定,
        同意回场,
        拒绝回场1太远,
        拒绝回场2太贵,
        拒绝回场3出差,
        实际回场
    }

    public class MyEnumSource
    {
        private static List<EnumContactResult> AvailableEnumContactResult = new List<EnumContactResult>();
        private static bool isInitialized = false;
        public static void Initialize()
        {
            AvailableEnumContactResult.Add(EnumContactResult.没有联络上);
            AvailableEnumContactResult.Add(EnumContactResult.还未决定);
            AvailableEnumContactResult.Add(EnumContactResult.同意回场);
            AvailableEnumContactResult.Add(EnumContactResult.拒绝回场1太远);
            AvailableEnumContactResult.Add(EnumContactResult.拒绝回场2太贵);
            AvailableEnumContactResult.Add(EnumContactResult.拒绝回场3出差);
            isInitialized = true;
        }
        public static List<EnumContactResult> GetEnumContactResult()
        {
            if (! isInitialized)
            {
                Initialize();
            }
            return AvailableEnumContactResult;
        }
    }
    [MarkupExtensionReturnType(typeof(object[]))]
    public class EnumValuesExtension : MarkupExtension 
    { 
        public EnumValuesExtension() 
        {
        }
        public EnumValuesExtension(Type enumType)
        {
            this.EnumType = enumType; 
        }
        [ConstructorArgument("enumType")]
        public Type EnumType 
        { 
            get; 
            set;
        } 
        public override object ProvideValue(IServiceProvider serviceProvider)
        { 
            if (this.EnumType == null)
                throw new ArgumentException("The enum type is not set");
            return Enum.GetValues(this.EnumType); 
        }
    } 
}
